package com.yuhs.zixing.study.design.pattern.dp002.create.c001.singleton;

/**
 * @description 懒汉式 同步代码块
 * @author: yuhs
 * @date 2022/3/30 下午3:54
 */
public class SingletonDemo006 {

    private SingletonDemo006() {
    }

    private static volatile SingletonDemo006 instance;

    public static SingletonDemo006 getInstance() {

        if (instance == null) {
            synchronized (SingletonDemo006.class) {
                if (instance == null) {
                    instance = new SingletonDemo006();
                }
            }
        }

        return instance;
    }
}
